<template>
    <div class="serviceManagement">
        <div class="selectValue">
            <label class="value">
                <span class="img">
                    <img src="@/assets/images/other/xnjc.png" />
                </span>
                <span class="title">服务器性能监测</span>
            </label>
            <!-- <div class="rightValue"><i class="el-icon-refresh-right" style="font-size: 20px; color: #3b8cfc"></i></div> -->
        </div>
        <div class="three">
            <div class="item">CPU使用率：50%</div>
            <div class="item">内存使用率：50%</div>
            <div class="item" style="margin: 0; width: calc((100% - 20px) / 3)">硬盘使用率：50%</div>
        </div>
        <navigation-bar>
            <div class="searchContent">
                <el-checkbox-group v-model="checkList">
                    <el-checkbox value="1" label="服务运行数量 50"></el-checkbox>
                    <el-checkbox value="2" label="服务停止数量 20"></el-checkbox>
                </el-checkbox-group>
            </div>
        </navigation-bar>
        <table-index
            :dataSource="dataSource"
            :tableColumns="tableColumns"
            :pageSize="pageSize"
            :pageCount="pageCount"
            :pageNo="pageNo"
            @pageChange="pageChange"
            :btnList="btnList"
            btnListWidth="60"
            @handleSelectionChange="handleSelectionChange"
        ></table-index>

        <div v-if="dialogShow">
            <custom-dialog :title="dialogTitle" size="large" @dialogClose="dialogClose"> 1111 </custom-dialog>
        </div>
    </div>
</template>

<script>
import customDialog from '@/components/customComponents/customDialog'
import tableIndex from '@/components/customComponents/customeTable/tableIndex'
import navigationBar from '@/components/customComponents/managementCenter/navigationBar'
// AjaxCommon
import {printAddress} from '@/libs/apiCommon'
import {CardId} from '@/libs/cardId'
import {PopupCommon} from '@/libs/popupCommon'
import {SessionCommon} from '@/libs/sessionCommon'
import {Utility} from '@/libs/utility'
import {serviceLogList} from '@/mockData/systemManage.js'
export default {
    components: {
        navigationBar,
        tableIndex,
        customDialog
    },
    data() {
        return {
            checkList: ['1', '2'],
            userName: '',
            value1: '',
            selectDeviceList: [],
            unitName: '',
            device_type: '',
            device_typeList: Utility.getDictList('oprType'),
            status: '',
            statusList: Utility.getDictList('status'),
            // table 相关参数  begin
            dataSource: serviceLogList,
            tableColumns: [
                {
                    prop: 'name',
                    label: '服务名称'
                },
                {
                    prop: 'remark',
                    label: '服务描述'
                },
                {
                    prop: 'serviceStatus',
                    label: '服务状态',
                    dictName: 'serviceStatus'
                }
            ],
            btnList: ['serviceStatus'],
            pageSize: 20,
            pageCount: 3,
            pageNo: 1
            // table 相关参数  end
        }
    },

    methods: {
        customClick(type) {
            if (this.selectDeviceList.length < 1) {
                PopupCommon.notify('info', '请选择至少一个机构')
                return
            }
            PopupCommon.notify('success', type == 1 ? '启用成功' : '禁用成功')
        },

        handleSelectionChange(d) {
            this.selectDeviceList = d
        },
        printClick() {
            console.log(1111)
            let urlAdd = `${printAddress}/ccdc/tmrreport/pdf/show?1=1&_u=file:shebeibqV1.tmrreport.xml&_i=1&_r=1
`
            if (this.selectDeviceList.length > 0) {
                let ids = this.selectDeviceList
                    .map((t) => {
                        return t.id
                    })
                    .join(',')
                if (this.selectDeviceList.length < 2) {
                    urlAdd += '&id=' + ids
                } else {
                    urlAdd += '&ids=' + ids
                }
            }
            console.log(urlAdd)
            window.open(urlAdd)
        },
        formInputChange(e) {
            if (e.filedName == 'idCard') {
                const data = CardId.getInfoByCardId(e.value)
                if (data) {
                    let newData = e.allData
                    newData['birthday'] = data.birthday
                    newData['sex'] = data.sex
                    this.$refs.form.changeFormValue(newData)
                }
            }
        },

        dialogClose() {
            this.dialogShow = false
        },
        dcData() {},
        searchClick() {
            this.pageNo = 1
            this.initPage()
        },
        resetClick() {
            this.unitName = ''
            this.device_type = ''
        },
        addClick() {
            let formConfigItem = this.formConfig
            formConfigItem.map((t) => {
                Object.keys(t).map((res) => {
                    if (res == 'fieldName') {
                        t.filedValue = ''
                    }
                })
            })
            this.formConfig = formConfigItem
            this.type = 'add'
            this.dialogShow = true
            this.dialogTitle = '新增' + JSON.parse(SessionCommon.getCurrentMenuInfo()).title
        },
        // 分页点击事件
        pageChange(p) {
            this.pageNo = p
            this.initPage()
        },

        // 初始化事件
        initPage() {
            //   let self = this;
            //   AjaxCommon("/ccdc/cfg/device/device/listByPage", "post", {
            //     unitName: this.unitName,
            //     deviceStatus: this.status,
            //     deviceType: this.device_type,
            //     pageNo: this.pageNo,
            //     pageSize: this.pageSize,
            //   }).then((res) => {
            //     if (res.data.code == 200) {
            //       self.dataSource = res.data.result.records;
            //       self.pageCount = res.data.result.total;
            //     } else {
            //       PopupCommon.notify("error", res.data.message);
            //     }
            //   });
        }
    },
    mounted() {
        this.initPage()
    }
}
</script>

<style lang="scss" scoped>
.serviceManagement {
    .deviceTitle {
        color: #333;
        float: right;
        label {
            font-size: 14px;
            float: left;
            margin-right: 10px;
        }
        img {
            width: 16px;
            float: left;
            margin-top: 10px;
            margin-right: 4px;
        }
    }
    .selectValue {
        display: flex;
        height: 50px;
        background: #fff;
        margin-top: 5px;
        border-radius: 4px;
        line-height: 50px;
        .value {
            margin-left: 20px;
            font-size: 16px;

            .img {
                display: block;
                float: left;
                margin-top: 9px;
            }
            .title {
                color: #333;
                margin-left: 10px;
            }
            .rightValue {
                flex: 1;
                text-align: right;
                margin-right: 20px;
                .btnList {
                    .hover {
                        border-color: #2680fa !important;
                    }
                    .btnItem {
                        display: inline-block;
                        height: 26px;
                        width: 60px;
                        margin-top: 7px;
                        margin-left: 10px;
                        line-height: 23px;
                        text-align: left;
                        border: 1px solid #e0e0e0;
                        border-radius: 4px;
                        cursor: pointer;
                        &:hover {
                            border-color: #2680fa;
                        }
                        &:first-child {
                            margin-left: 0 !important;
                        }
                        svg {
                            margin-top: 2px;
                            float: left;
                            margin-left: 8px;
                            margin-right: 3px;
                        }
                        label {
                            font-size: 14px;
                        }
                    }
                }
                span {
                    font-size: 16px;
                    color: #666;
                    b {
                        font-size: 16px;
                        color: #333;
                    }
                    label {
                        width: 10px;
                        display: inline-block;
                        height: 10px;
                        border-radius: 10px;
                        margin-left: 40px;
                        margin-right: 5px;
                    }
                }
            }
        }
    }
    .three {
        margin: 10px 0;
        display: flex;
        justify-content: flex-start;
        flex-wrap: wrap;
        .item {
            margin-right: 10px;
            width: calc((100% - 30px) / 3);
            height: 110px;
            position: relative;
            cursor: pointer;
            background-color: #fff;
            border: 1px solid #e0e0e0;
            border-radius: 4px;
            line-height: 110px;
            text-align: center;
            font-size: 20px;
        }
    }
    .mcTableIndex {
        height: calc(100vh - 355px);
    }
}
</style>
